import { mapState } from 'vuex'
import { MANAGER_ROLE_CODE } from "@/const";

export default {
    computed: {
        ...mapState([ 'loginerRole', 'modifyPass' ])
    },
    watch: {
        '$route.name': function() {
            this.checkChangePassword()
        }
    },
    mounted() {
        this.checkChangePassword()
    },
    methods: {
        checkChangePassword() {
            if (
                this.modifyPass 
                && this.loginerRole === MANAGER_ROLE_CODE 
                && this.$route.name !== 'changePassword'
            ) {
                this.$router.push('/changePassword')
            }
        }
    }
}